import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/material.dart';

import 'package:get/get.dart';

import 'dart:math' as math;

import 'package:live_music/components/ui/theme.dart';
import 'package:live_music/models/square_images_model.dart';
import 'package:live_music/pages/detail/moment_detail.dart';
import 'package:live_music/utils/cgq_utils.dart';

class ImageSwiperCard extends StatefulWidget {
  const ImageSwiperCard({Key key, this.squareImageListModel, this.date})
      : super(key: key);
  final List<SquareImageModel> squareImageListModel;
  final String date;
  @override
  State<ImageSwiperCard> createState() => _ImageSwiperCardState();
}

class _ImageSwiperCardState extends State<ImageSwiperCard> {
  @override
  Widget build(BuildContext context) {
    double boxWidth = MediaQuery.of(context).size.width - 24;
    return Column(
      children: [
        Container(
          padding:
              const EdgeInsets.only(top: 16, bottom: 16, right: 24, left: 24),
          alignment: Alignment.centerLeft,
          child: Text(widget.date),
        ),
        Container(
          width: boxWidth,
          margin: const EdgeInsets.only(top: 8, right: 16, left: 16, bottom: 8),
          child: Wrap(
            spacing: 4,
            runSpacing: 4,
            children: widget.squareImageListModel
                .map((e) => InkWell(
                    onTap: () => {Get.to(MomentDetailPage(id: e.momentId))},
                    child: SizedBox(
                      width: 108,
                      height: 108,
                      child: ClipRRect(
                        borderRadius: BorderRadius.circular(4),
                        child: CgqUtils.imageCache(e.url, fit: BoxFit.cover),
                      ),
                    )))
                .toList(),
          ),
        )
      ],
    );
  }
}
